package com.mrjy.common.util;
import org.springframework.beans.BeansException;  
import org.springframework.context.ApplicationContext;  
import org.springframework.context.ApplicationContextAware;  
  
/**
 * 用于加载Spring上下文环境,得到Spring容器中的Bean
 * @author Administrator
 *
 */
public class SpringContextHelper implements ApplicationContextAware {  
    private static ApplicationContext context = null;  
  
    @Override  
    public void setApplicationContext(ApplicationContext applicationContext)  
            throws BeansException {  
        context = applicationContext;  
    }  
      
    public static Object getBean(String name){  
        return context.getBean(name);
    }

    public static Object getBean(Class name) {
        return context.getBean(name);
    }

} 